import { useRoutes } from 'react-router-dom';
import Home from '@/pages/home';
import WinTogether from '@/pages/win-together';
import Csr from '@/pages/csr';
import Gongyi from '@/pages/gongyi';
import InvestorRelations from '@/pages/investor-relations';
import TechNology from '@/pages/technology';
import { SmileOutlined } from '@ant-design/icons';
import Playground from '@/pages/gongyi/playground';
import { t } from '@/components/i18n';

export const routeConfig = () => [
  {
    path: '/',
    element: <Home />,
    name: t('homeTab'),
    showMenu: false,
    items: []
  },
  {
    path: '/win-together',
    element: <WinTogether />,
    name: t('teamworkTab'),
    showMenu: false,
  },
  {
    path: '/technology',
    element: <TechNology />,
    name: t('technologyTab'),
    showMenu: false,
  },
  {
    path: '/csr',
    element: <Csr />,
    name: t('csrTab'),
    showMenu: true,
    items: [
      {
        key: '1',
        label: (
          <a target="_blank" rel="noopener noreferrer" href="https://www.antgroup.com">
            1st menu item
          </a>
        ),
      },
      {
        key: '2',
        label: (
          <a target="_blank" rel="noopener noreferrer" href="https://www.aliyun.com">
            2nd menu item (disabled)
          </a>
        ),
        icon: <SmileOutlined />,
        disabled: true,
      },
      {
        key: '3',
        label: (
          <a target="_blank" rel="noopener noreferrer" href="https://www.luohanacademy.com">
            3rd menu item (disabled)
          </a>
        ),
        disabled: true,
      },
      {
        key: '4',
        danger: true,
        label: 'a danger item',
      },
    ]
  },
  {
    path: '/gongyi/playground',
    element: <Playground />,
    name: t('playgroundTab'),
    hide: true
  },
  {
    path: '/gongyi',
    element: <Gongyi />,
    name: t('gongyiTab'),
    showMenu: true,
    items: [
      {
        key: '/gongyi/playground',
        label: t('playgroundTab'),
      },
      {
        key: '2',
        label: (
          <a target="_blank" rel="noopener noreferrer" href="https://www.meituan.org.cn/">
            {t('foundationTab')}
          </a>
        ),
        icon: <SmileOutlined />,
      },
    ]
  },
  {
    path: '/investor-relations',
    element: <InvestorRelations />,
    name: t('investorRelationsTab'),
    showMenu: false,
  },
  {
    name: t('joinUsTab'),
    link: 'https://zhaopin.meituan.com/web/home?source=mtgw',
    showMenu: false,
  }
]

const Router = () => {
  return useRoutes(routeConfig());
};

export default Router;
